#!/bin/bash
# 精英杂志PWA功能Git提交脚本 - Git Bash版本

echo "🚀 开始PWA功能Git提交..."

# 进入项目目录
cd "/c/Users/Administrator/Documents/trae_projects/lt00001/magazine" || exit 1

echo "📁 当前目录: $(pwd)"

# 检查Git状态
echo "📊 检查Git状态..."
git status

# 添加所有PWA相关文件
echo "📝 添加PWA文件..."
git add manifest.json service-worker.js offline.html static/offline-test.html
git add static/css/mobile-optimization.css static/css/pwa-styles.css static/css/pwa-install.css
git add static/js/pwa-installer.js static/js/pwa-install.js
git add themes/magazine-theme/layouts/_default/baseof.html themes/magazine-theme/layouts/index.html
git add PWA_IMPLEMENTATION_SUMMARY.md validate_pwa.py simple_server.py

# 提交更改
echo "💾 提交更改..."
git commit -m "feat: 添加完整的PWA功能实现

- 添加Web App Manifest配置
- 实现Service Worker缓存策略  
- 添加PWA安装提示功能
- 优化移动端适配和响应式设计
- 添加离线功能和测试工具
- 更新主题模板支持PWA"

# 推送到远程仓库
echo "🔄 推送到远程仓库..."
git push -u origin main

if [ $? -eq 0 ]; then
    echo "✅ PWA功能推送成功！"
    echo "🔄 GitHub Actions将自动同步到Gitee"
else
    echo "❌ 推送失败，请检查远程仓库配置"
    echo "🔧 请配置远程仓库："
    echo "   git remote add origin https://gitee.com/你的用户名/magazine.git"
    echo "   或："
    echo "   git remote add origin https://github.com/你的用户名/magazine.git"
fi

echo "🎉 操作完成！"